/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sk.tuke.magsa.tools.metamodel.constraints;

import sk.tuke.magsa.tools.metamodel.Type;
import yajco.annotation.Before;
import yajco.annotation.Token;

/**
 *
 * @author z00385rz
 */
public class Regex extends Constraint{
    private String regex;
    
    @Before("regex")
    public Regex(@Token("STRING_VALUE")String regex)
    {
        this.regex = regex;
    }
    
    public String getRegex()
    {       
        String[] str;
        String str1;
        if(this.regex.contains("\\"))
        {
            str = this.regex.split("\\\\");
            str[0] += "\\";
            str[0] += "\\";
            str1 = str[0] + str[1];
            return str1;
        }
        return this.regex;
    }

    @Override
    public boolean supportsType(Type type) {
        return type.equals(Type.STRING);
    }
}
